<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * BugReport filter form base class.
 *
 * @package    filters
 * @subpackage BugReport *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseBugReportFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'           => new sfWidgetFormFilterInput(),
      'owner_id'       => new sfWidgetFormDoctrineChoice(array('model' => 'User', 'add_empty' => true)),
      'conditions'     => new sfWidgetFormFilterInput(),
      'fields'         => new sfWidgetFormFilterInput(),
      'group_by'       => new sfWidgetFormFilterInput(),
      'sort_by'        => new sfWidgetFormFilterInput(),
      'sort_direction' => new sfWidgetFormChoice(array('choices' => array('' => '', 'ASC' => 'ASC', 'DESC' => 'DESC'))),
    ));

    $this->setValidators(array(
      'name'           => new sfValidatorPass(array('required' => false)),
      'owner_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'User', 'column' => 'id')),
      'conditions'     => new sfValidatorPass(array('required' => false)),
      'fields'         => new sfValidatorPass(array('required' => false)),
      'group_by'       => new sfValidatorPass(array('required' => false)),
      'sort_by'        => new sfValidatorPass(array('required' => false)),
      'sort_direction' => new sfValidatorChoice(array('required' => false, 'choices' => array('ASC' => 'ASC', 'DESC' => 'DESC'))),
    ));

    $this->widgetSchema->setNameFormat('bug_report_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'BugReport';
  }

  public function getFields()
  {
    return array(
      'id'             => 'Number',
      'name'           => 'Text',
      'owner_id'       => 'ForeignKey',
      'conditions'     => 'Text',
      'fields'         => 'Text',
      'group_by'       => 'Text',
      'sort_by'        => 'Text',
      'sort_direction' => 'Enum',
    );
  }
}